package com.study.guapo.singleton.lazy;

/**
 * @ClassName: LazySingleton
 * @Description: 懒汉式单例
 * @author: Adminstrator
 * @Date: 2019-03-10 16:49
 */
public class LazySingleton {

    private LazySingleton(){
        if(LazyHolder.LAZY != null){
            throw new RuntimeException("不允许创建多个实例");
        }
    }

    public static final LazySingleton getInstance(){
        return LazyHolder.LAZY;
    }

    //默认不加载
    private static class LazyHolder{
        private static final LazySingleton LAZY = new LazySingleton();
    }
}
